package com.cskaoyan.catmall.service.Impl;

import com.cskaoyan.catmall.dao.RegionMapper;
import com.cskaoyan.catmall.model.vo.RegionInnerListVo;
import com.cskaoyan.catmall.model.vo.RegionListVo;
import com.cskaoyan.catmall.service.RegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 创建日期: 2022-01-07-08-51
 * author : WQW
 * description: 行政区域相关操作
 */
@Service
public class RegionServiceImpl implements RegionService {

    @Autowired
    RegionMapper regionMapper;

    /**
     * @param
     * @return java.util.List<com.cskaoyan.catmall.model.vo.RegionListVo>
     * @description 获取行政区域列表
     * @author WQW
     * @date 2022/1/7 8:54
     */
    @Cacheable( value = "region" ,key = "'list'" )
    @Override
    public RegionListVo getRegionList() {
        final Integer PROVINCE_PID = 0;// pid表示省份对应的pid
        final Integer PAGE = 1;
        final Integer PAGES = 1;
//        List<RegionInnerListVo> regionInnerListVoList = regionMapper.selectRegion(PROVINCE_PID);
        List<RegionInnerListVo> regionInnerListVoList = regionMapper.selectRegionList();
        return new RegionListVo(regionInnerListVoList.size(), PAGES, regionInnerListVoList.size(), PAGE, regionInnerListVoList);
    }
}
